﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net;
using Microsoft.Http;
using System.Xml.Xsl;
using System.Xml;

namespace WoodbaseVideoRental.UserControls
{
    public partial class LatestMovies : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            using (HttpClient client = new HttpClient("http://localhost:9090/WVRServices/"))
            {
                using(HttpResponseMessage msg = client.Get("Movies"))
                {
                    //XNamespace ns = "http://schemas.datacontract.org/2004/07/Woodbase.CodeBase.WVR.Objects";
                    msg.EnsureStatusIsSuccessful();
                    XElement content = msg.Content.ReadAsXElement();

                    xmlMovies.DocumentContent = content.ToString();
                    xmlMovies.TransformSource = Server.MapPath("/Styles/XSLT/LatestMovies.xslt");
                    xmlMovies.DataBind();
                }
            }
        }
    }
}